package com.trace.pplos.parse.dao.dataobject;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

public class TzhyInfo {
    private static final Logger logger = LoggerFactory.getLogger(TzhyInfo.class);

    private Integer id;

    private String industryType;

    private String industryName;

    private String photoPath;

    private String generalPhotoPath;

    private String doorPhotoPath;

    private String licensePhotoPath;

    private String headName;

    private String headPhone;

    private String headIdcard;

    private String lng;

    private String lat;

    private String addr;

    private String lngGps;

    private String latGps;

    private String cjdw;

    private String filepath;

    private String locMapSnapPath;

    private Date gmtCreate;

    private String gmtCreateUser;

    private Date gmtModified;

    private String gmtModifiedUser;

    private Integer status;

    public TzhyInfo(Integer id, String industryType, String industryName, String photoPath, String generalPhotoPath, String doorPhotoPath, String licensePhotoPath, String headName, String headPhone, String headIdcard, String lng, String lat, String addr, String lngGps, String latGps, String cjdw, String filepath, String locMapSnapPath, Date gmtCreate, String gmtCreateUser, Date gmtModified, String gmtModifiedUser, Integer status) {
        this.id = id;
        this.industryType = industryType;
        this.industryName = industryName;
        this.photoPath = photoPath;
        this.generalPhotoPath = generalPhotoPath;
        this.doorPhotoPath = doorPhotoPath;
        this.licensePhotoPath = licensePhotoPath;
        this.headName = headName;
        this.headPhone = headPhone;
        this.headIdcard = headIdcard;
        this.lng = lng;
        this.lat = lat;
        this.addr = addr;
        this.lngGps = lngGps;
        this.latGps = latGps;
        this.cjdw = cjdw;
        this.filepath = filepath;
        this.locMapSnapPath = locMapSnapPath;
        this.gmtCreate = gmtCreate;
        this.gmtCreateUser = gmtCreateUser;
        this.gmtModified = gmtModified;
        this.gmtModifiedUser = gmtModifiedUser;
        this.status = status;
    }

    public TzhyInfo() {
        super();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getIndustryType() {
        return industryType;
    }

    public void setIndustryType(String industryType) {
        this.industryType = industryType == null ? null : industryType.trim();
    }

    public String getIndustryName() {
        return industryName;
    }

    public void setIndustryName(String industryName) {
        this.industryName = industryName == null ? null : industryName.trim();
    }

    public String getPhotoPath() {
        return photoPath;
    }

    public void setPhotoPath(String photoPath) {
        this.photoPath = photoPath == null ? null : photoPath.trim();
    }

    public String getGeneralPhotoPath() {
        return generalPhotoPath;
    }

    public void setGeneralPhotoPath(String generalPhotoPath) {
        this.generalPhotoPath = generalPhotoPath == null ? null : generalPhotoPath.trim();
    }

    public String getDoorPhotoPath() {
        return doorPhotoPath;
    }

    public void setDoorPhotoPath(String doorPhotoPath) {
        this.doorPhotoPath = doorPhotoPath == null ? null : doorPhotoPath.trim();
    }

    public String getLicensePhotoPath() {
        return licensePhotoPath;
    }

    public void setLicensePhotoPath(String licensePhotoPath) {
        this.licensePhotoPath = licensePhotoPath == null ? null : licensePhotoPath.trim();
    }

    public String getHeadName() {
        return headName;
    }

    public void setHeadName(String headName) {
        this.headName = headName == null ? null : headName.trim();
    }

    public String getHeadPhone() {
        return headPhone;
    }

    public void setHeadPhone(String headPhone) {
        this.headPhone = headPhone == null ? null : headPhone.trim();
    }

    public String getHeadIdcard() {
        return headIdcard;
    }

    public void setHeadIdcard(String headIdcard) {
        this.headIdcard = headIdcard == null ? null : headIdcard.trim();
    }

    public String getLng() {
        return lng;
    }

    public void setLng(String lng) {
        this.lng = lng == null ? null : lng.trim();
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat == null ? null : lat.trim();
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr == null ? null : addr.trim();
    }

    public String getLngGps() {
        return lngGps;
    }

    public void setLngGps(String lngGps) {
        this.lngGps = lngGps == null ? null : lngGps.trim();
    }

    public String getLatGps() {
        return latGps;
    }

    public void setLatGps(String latGps) {
        this.latGps = latGps == null ? null : latGps.trim();
    }

    public String getCjdw() {
        return cjdw;
    }

    public void setCjdw(String cjdw) {
        this.cjdw = cjdw == null ? null : cjdw.trim();
    }

    public String getFilepath() {
        return filepath;
    }

    public void setFilepath(String filepath) {
        this.filepath = filepath == null ? null : filepath.trim();
    }

    public String getLocMapSnapPath() {
        return locMapSnapPath;
    }

    public void setLocMapSnapPath(String locMapSnapPath) {
        this.locMapSnapPath = locMapSnapPath == null ? null : locMapSnapPath.trim();
    }

    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public String getGmtCreateUser() {
        return gmtCreateUser;
    }

    public void setGmtCreateUser(String gmtCreateUser) {
        this.gmtCreateUser = gmtCreateUser == null ? null : gmtCreateUser.trim();
    }

    public Date getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(Date gmtModified) {
        this.gmtModified = gmtModified;
    }

    public String getGmtModifiedUser() {
        return gmtModifiedUser;
    }

    public void setGmtModifiedUser(String gmtModifiedUser) {
        this.gmtModifiedUser = gmtModifiedUser == null ? null : gmtModifiedUser.trim();
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public static TzhyInfo toBean(String object){
        try{
            TzhyInfo info = new TzhyInfo();
            JSONObject record = JSON.parseObject(object);
            info.setIndustryType(record.getString("hylx"));
            info.setIndustryName(record.getString("hymc"));
            info.setHeadName(record.getString("fzr"));
            info.setHeadPhone(record.getString("dhhm"));
            info.setHeadIdcard(null);

            info.setLat(record.getString("latitude"));
            info.setLng(record.getString("longitude"));

            info.setGmtCreate(record.getDate("createdAt"));
            info.setGmtCreateUser(record.getString("createdBy"));
            //info.setGmtModified(record.getDate("modifiedAt"));
            info.setGmtModified(new Date());
            info.setGmtModifiedUser(record.getString("modifiedBy"));

            //概貌照片
            String filePaths = "";
            JSONArray list = record.getJSONArray("gmzpPictureList");
            for (int i = 0; i < list.size(); i++) {
                JSONObject dataObj = list.getJSONObject(i);
                filePaths += dataObj.getString("path") +",";
            }
            info.setGeneralPhotoPath(filePaths);

            //大门照片
            filePaths = "";
            list = record.getJSONArray("dmzpPictureList");
            for (int i = 0; i < list.size(); i++) {
                JSONObject dataObj = list.getJSONObject(i);
                filePaths += dataObj.getString("path") +",";
            }
            info.setDoorPhotoPath(filePaths);

            //营业执照
            filePaths = "";
            list = record.getJSONArray("yyzzPictureList");
            for (int i = 0; i < list.size(); i++) {
                JSONObject dataObj = list.getJSONObject(i);
                filePaths += dataObj.getString("path") +",";
            }
            info.setLicensePhotoPath(filePaths);
            return info;
        }catch (Exception e){
            logger.error(e.getMessage(), e);
        }
        return null;
    }
}